package org.osgroup.controller;

import org.osgroup.dto.HeartbeatResponse;
import org.osgroup.service.HeartbeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 系统监控接口控制器
 */
@RestController
@RequestMapping("/api/system")
@CrossOrigin(origins = "*")
public class SystemController {
    
    @Autowired
    private HeartbeatService heartbeatService;
    
    /**
     * 获取系统心跳状态
     */
    @GetMapping("/heartbeat")
    public ResponseEntity<HeartbeatResponse> getHeartbeat() {
        try {
            HeartbeatResponse response = heartbeatService.getHeartbeatStatus();
            return ResponseEntity.ok(response);
        } catch (Exception e) {
            return ResponseEntity.status(500).build();
        }
    }
}
